home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Punkte2.cpp < prev    next >
C/C++ Source or Header  |  1998-12-26  |  1KB  |  38 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Punkte2.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. const int FMax = 16;
  10. TColor Farbe[FMax] =
  11.   {clBlack, clMaroon, clGreen, clNavy, clTeal, clPurple,
  12.    clOlive, clGray, clSilver, clRed, clLime, clBlue,
  13.    clAqua, clFuchsia, clYellow, clWhite};
  14.  
  15. TForm1 *Form1;
  16. //---------------------------------------------------------------------------
  17. __fastcall TForm1::TForm1(TComponent* Owner)
  18.     : TForm(Owner)
  19. {
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TForm1::Button1Click(TObject *Sender)
  23. {
  24.   int x,y;
  25.   for (int i=1; i<10000; i++)
  26.   {
  27.     x = random(ClientWidth);
  28.     y = random(ClientHeight);
  29.     Canvas->Pixels[x][y] = Farbe[random(FMax)];
  30.   }
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TForm1::FormCreate(TObject *Sender)
  34. {
  35.   randomize ();
  36.   Color = Farbe [random(FMax/2)];
  37. }
  38. //---------------------------------------------------------------------------